package com.example.demo.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
public class Cashbackrecord {
    private int recordId;
    private Timestamp paymentDate;
    private int period;
    private BigDecimal returnMoney;
    private int yesNo;
    private String owner;
    private Client kh;
    private Order htdd;

    @Id
    @Column(name = "record_id", nullable = false)
    public int getRecordId() {
        return recordId;
    }

    public void setRecordId(int recordId) {
        this.recordId = recordId;
    }

    @Basic
    @Column(name = "payment_date", nullable = false)
    public Timestamp getPaymentDate() {
        return paymentDate;
    }

    public void setPaymentDate(Timestamp paymentDate) {
        this.paymentDate = paymentDate;
    }

    @Basic
    @Column(name = "period", nullable = false)
    public int getPeriod() {
        return period;
    }

    public void setPeriod(int period) {
        this.period = period;
    }

    @Basic
    @Column(name = "return_money", nullable = false, precision = 2)
    public BigDecimal getReturnMoney() {
        return returnMoney;
    }

    public void setReturnMoney(BigDecimal returnMoney) {
        this.returnMoney = returnMoney;
    }

    @Basic
    @Column(name = "yes_no", nullable = false)
    public int getYesNo() {
        return yesNo;
    }

    public void setYesNo(int yesNo) {
        this.yesNo = yesNo;
    }

    @Basic
    @Column(name = "owner", nullable = true, length = 255)
    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Cashbackrecord that = (Cashbackrecord) o;
        return recordId == that.recordId &&
                period == that.period &&
                yesNo == that.yesNo &&
                Objects.equals(paymentDate, that.paymentDate) &&
                Objects.equals(returnMoney, that.returnMoney) &&
                Objects.equals(owner, that.owner);
    }

    @Override
    public int hashCode() {
        return Objects.hash(recordId, paymentDate, period, returnMoney, yesNo, owner);
    }

    @ManyToOne
    @JoinColumn(name = "client_id", referencedColumnName = "client_id", nullable = false)
    public Client getKh() {
        return kh;
    }

    public void setKh(Client kh) {
        this.kh = kh;
    }

    @OneToOne
    @JoinColumn(name = "order_id", referencedColumnName = "order_id", nullable = false)
    public Order getHtdd() {
        return htdd;
    }

    public void setHtdd(Order htdd) {
        this.htdd = htdd;
    }
}
